<?php

namespace App\Http\Controllers\user;

use App\Dao\CarsDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;

class CarsController extends BaseController
{
    public function addCar(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,CarsDao::add_car($params));
    }


    public function inc_dec_car(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,CarsDao::inc_dec_car($params));
    }


    /**
     * @throws SysExceptions
     */
    public function del_car(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        CarsDao::del_car($params);
        return Code::message('',200);
    }

    /**
     * @throws SysExceptions
     */
    public function del_cars(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        CarsDao::del_cars($params);
        return Code::message('',200);
    }


    public function get_cars(): array
    {
        $user_id = getUserToken();
        return Code::message('',200,CarsDao::get_cars([
            'user_id'=>$user_id
        ]));
    }
}
